Ext.define('FirstMate.store.MarineWeather', {
	requires : ['FirstMate.model.MarineWeather'],
	extend : 'Ext.data.Store',
	config : {
		storeId: 'marineWeatherStore',	   
		model : 'FirstMate.model.MarineWeather',
		proxy :  {
			type: 'jsonp',
			callbackKey : 'callback',
			autoAppendParams : true,
			extraParams: {
	            key: 'mwbmeh9tq25kqcctb4nvmdm5',
	            format: 'json',
	            includelocation : 'yes'
	        },
			enablePagingParams : false,
			noCache : false,                               
			url : 'http://api.worldweatheronline.com/free/v1/marine.ashx?' +
			'q=0%2C0',
			reader: new Ext.data.reader.Array({
				type: 'json',
				rootProperty: 'data'
			})
		}
	},
	loadWeather : function (position) {
		
		this.setProxy( {
			type: 'jsonp',
			callbackKey : 'callback',
			autoAppendParams : true,
			extraParams: {
	            key: 'mwbmeh9tq25kqcctb4nvmdm5',
	            format: 'json',
	            includelocation : 'yes'
	        },
			enablePagingParams : false,
			noCache : false,                               
			url : 	'http://api.worldweatheronline.com/free/v1/marine.ashx?' +
					'q=' + position.lat() + 
					'%2C' + 
					position.lng(),
			reader: new Ext.data.reader.Array({
				type: 'json',
				rootProperty: 'data'
			})
		}
		);
		//this.removeAll();
		this.load();
	}
});
